package com.health.viewscontrols.medical.base;

import android.util.Log;

import com.health.viewscontrols.medical.device.ah.AHAolActivity;
import com.health.viewscontrols.medical.device.ah.AHF701Activity;
import com.health.viewscontrols.medical.device.ah.AHYuyueActivity;
import com.health.viewscontrols.medical.device.bf.BFEjyhActivity;
import com.health.viewscontrols.medical.device.bf.BFEjyhShyActivity;
import com.health.viewscontrols.medical.device.bg.BGAALActivity;
import com.health.viewscontrols.medical.device.bg.BGSannuo2000Activity;
import com.health.viewscontrols.medical.device.bg.BGSannuoActivity;
import com.health.viewscontrols.medical.device.bg.BGyuyueActivity;
import com.health.viewscontrols.medical.device.bg.BJSHYActivity;
import com.health.viewscontrols.medical.device.bg.VivaActivity;
import com.health.viewscontrols.medical.device.bo.BOBeiRuiActivity;
import com.health.viewscontrols.medical.device.bo.BOYuyueActivity;
import com.health.viewscontrols.medical.device.bp.BPYuyueActivity;
import com.health.viewscontrols.medical.device.bp.FSRKBb4Activity;
import com.health.viewscontrols.medical.device.comp.DhCompositionActivity;
import com.health.viewscontrols.medical.device.ecg.ECGPM10Activity;
import com.health.viewscontrols.medical.device.fm.DhFMActivity;
import com.health.viewscontrols.medical.device.pef.PEFActivity;
import com.health.viewscontrols.medical.device.waist.WaistActivity;
import com.health.viewscontrols.medical.device.xhdb.BJXHDBActivity;
import com.health.viewscontrols.medical.device.bo.BOCmmActivity;
import com.health.viewscontrols.medical.device.bo.BOKrkActivity2;
import com.health.viewscontrols.medical.device.bp.BPAALActivity;
import com.health.viewscontrols.medical.device.bp.BPMbb4Activity;
import com.health.viewscontrols.medical.device.ecg.ECGLKActivity;
import com.health.viewscontrols.medical.device.fm.FMQingActivity;
import com.health.viewscontrols.medical.device.ue.UEEMPActivity;
import com.health.viewscontrols.medical.device.xhdb.LysunXHDBActivity;
import com.nova.health.ble.BleConfigConstants;
import com.nova.health.ble.R;
import com.novabluetooth.views.twj.TwjConstans;
import com.orhanobut.hawk.Hawk;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * author : xiaoxin
 * date   : 2021/2/22 16:38
 * desc   :
 * update :
 */
public enum DeviceEnum implements Serializable {

    BP("bp", true, "血压心率", "脉波血压计4.0", "", "MAIBOBO4",
            "脉搏波", R.drawable.icon_bp, R.drawable.shape_bp, BPMbb4Activity.class,false),
    BP2("BP2", true, "爱奥乐血压", TwjConstans.Bioland_BP_NAME, "", "MAIBOBO4",
            "爱奥乐", R.drawable.icon_bp, R.drawable.shape_bp, BPAALActivity.class,true),
    BP3("BP3", true, "鱼跃血压", "鱼跃血压计", "", "MAIBOBO4",
            "鱼跃", R.drawable.icon_bp, R.drawable.shape_bp, BPYuyueActivity.class,false),
    BP4("BP4", true, "辰浩血压", "辰浩血压计", "", "MAIBOBO4",
            "辰浩", R.drawable.icon_bp, R.drawable.shape_bp, FSRKBb4Activity.class,true),
    BG("bg", true, "血糖", "三诺WL-1型血糖仪", "", "XUETANG",
            "血糖", R.drawable.icon_bg_ble, R.drawable.shape_bg, BGSannuoActivity.class,false),
    BG2("BG2", true, "爱奥乐血糖", "爱奥乐血糖", "", "XUETANG",
            "血糖", R.drawable.icon_bg_ble, R.drawable.shape_bg, BGAALActivity.class,false),
    BG3("BG3", true, "鱼跃血糖", "鱼跃血糖", "", "XUETANG",
            "血糖", R.drawable.icon_bg_ble, R.drawable.shape_bg, BGyuyueActivity.class,false),
    BG4("bg4", true, "三诺臻准2000血糖", "三诺臻准2000血糖", "", "XUETANG",
            "血糖", R.drawable.icon_bg_ble, R.drawable.shape_bg, BGSannuo2000Activity.class,false),
    FM("fm", false, "身高体重", "轻加体脂秤", "", "newTIZHONGQing",
            "", R.drawable.icon_height, R.drawable.shape_fat, FMQingActivity.class,true),
    FM2("FM2", true, "DH身高体重秤", "DH身高体重秤", "", "FM2",
            "", R.drawable.icon_height, R.drawable.shape_fat, DhFMActivity.class,false),
    AH("ah", true, "体温", "爱奥乐体温计", "", "Bioland-IT",
            "爱奥乐体温计", R.drawable.icon_ah, R.drawable.shape_ah, AHAolActivity.class,true),
    AH2("ah2", true, "鱼跃体温", "鱼跃体温计", "", "Bioland-IT",
            "鱼跃体温计", R.drawable.icon_ah, R.drawable.shape_ah, AHYuyueActivity.class,false),
    AH3("ah3", true, "辰浩体温计", "辰浩体温计", "", "Bioland-IT",
            "辰浩体温计", R.drawable.icon_ah, R.drawable.shape_ah, AHF701Activity.class,false),
    BO("bo", true, "血氧", "科瑞康血氧", "", "XUEYANG",
            "科瑞康血氧", R.drawable.icon_bo, R.drawable.shape_bo, BOKrkActivity2.class,false),
    BO2("BO2", true, "血氧CHS", "血氧CHS", "", "XUEYANG",
            "ChoiceMMed_C208S", R.drawable.icon_bo, R.drawable.shape_bo, BOCmmActivity.class,false),
    BO3("BO3", true, "鱼跃血氧", "鱼跃血氧", "", "XUEYANG",
            "鱼跃血氧", R.drawable.icon_bo, R.drawable.shape_bo, BOYuyueActivity.class,false),
    BO4("BO4", true, "贝瑞血氧", "贝瑞血氧", "", "XUEYANG",
            "贝瑞血氧", R.drawable.icon_bo, R.drawable.shape_bo, BOBeiRuiActivity.class,true),
    ECG("ecg", false, "心电图", "单导", "", "ECG",
            "心电", R.drawable.icon_ecg, R.drawable.shape_ecg, ECGLKActivity.class,true),
    ECG1("ecg1", false, "心电PM10", "PM10", "", "ECG",
            "心电", R.drawable.icon_ecg, R.drawable.shape_ecg, ECGPM10Activity.class,false),
    UE("ue", true, "尿常规", "尿常规", "", "BLE-EMP-Ui",
            "恩普生", R.drawable.icon_ue, R.drawable.shape_ue, UEEMPActivity.class,true),
    BF("bf", true, "血脂", "e家医护", "", "PW-01",
            "e家医护", R.drawable.icon_bf, R.drawable.shape_bf, BFEjyhActivity.class,false),
    BF1("BF", true, "e家医护三合一", "e家医护三合一", "", "PW-01",
            "e家医护", R.drawable.icon_bf, R.drawable.shape_bf, BFEjyhShyActivity.class,true),
    BG_BAI_JIE("bg_bai_jie", true, "百捷三合一", "百捷设备", "", "BeneCheck",
            "BeneCheck",R.drawable.icon_bg_ble, R.drawable.shape_bg, BJSHYActivity.class,false),
    XHDB_BAI_JIE("XHDB", true, "百捷血红蛋白", "百捷血红蛋白", "", "BeneCheck TC-B DONGLE",
            "血红蛋白",R.drawable.icon_bg_ble, R.drawable.shape_bg, BJXHDBActivity.class,false),
    XHDB_LYSUN("XHDB2", true, "e家血红蛋白", "e家血红蛋白", "", "LYSUN BHM-101",
            "血红蛋白",R.drawable.icon_bg_ble, R.drawable.shape_bg, LysunXHDBActivity.class,false),
    VIVA("viva", true, "微策三合一", "微策三合一", "", "BeneCheck",
            "BeneCheck",R.drawable.icon_bg_ble, R.drawable.shape_bg, VivaActivity.class,true),
    RTCF_DH("RTCF_DH", true, "DH人体成分", "DH人体成分", "", "RTCF_DH",
            "DH人体成分",R.drawable.icon_component, R.drawable.shape_bg, DhCompositionActivity.class,false),
    PEF("PEF", true, "肺功能", "肺功能", "", "PEF_SP",
            "肺功能", R.drawable.icon_ecg, R.drawable.shape_ecg, PEFActivity.class,true),
    WAIST("WAIST", true, "腰臀比", "腰臀比", "", "WAIST",
            "腰臀比",R.drawable.icon_bg_ble, R.drawable.shape_bg, WaistActivity.class,false);

    public static List<DeviceEnum> getDeviceList() {
        List<DeviceEnum> deviceEnumList = new ArrayList<>();
        deviceEnumList.add(BP);
        deviceEnumList.add(BP2);
        deviceEnumList.add(BP3);
        deviceEnumList.add(BP4);
        deviceEnumList.add(BG);
        deviceEnumList.add(BG2);
        deviceEnumList.add(BG3);
        deviceEnumList.add(FM);
        deviceEnumList.add(FM2);
        deviceEnumList.add(AH);
        deviceEnumList.add(AH2);
        deviceEnumList.add(AH3);
        deviceEnumList.add(BO);
        deviceEnumList.add(BO2);
        deviceEnumList.add(BO3);
        deviceEnumList.add(BO4);
        deviceEnumList.add(ECG);
        deviceEnumList.add(ECG1);
        deviceEnumList.add(UE);
        deviceEnumList.add(BF);
        deviceEnumList.add(BF1);
        deviceEnumList.add(BG_BAI_JIE);
        deviceEnumList.add(XHDB_BAI_JIE);
        deviceEnumList.add(XHDB_LYSUN);
        deviceEnumList.add(VIVA);
        deviceEnumList.add(BG4);
        deviceEnumList.add(WAIST);
        deviceEnumList.add(RTCF_DH);
        deviceEnumList.add(PEF);
        return deviceEnumList;
    }

    public static List<DeviceEnum> getConfig() {
        List<String> enumList = Hawk.get(BleConfigConstants.TJ_CONFIG_LIST, null);
        Log.e("xiaoxin", "getConfig: " + enumList );
        List<DeviceEnum> deviceEnumList = DeviceEnum.getDeviceList();
        if (enumList == null) {
            //enumList == null 代表没有配置过，默认配置全部项目
//            for (int i = 0; i < deviceEnumList.size(); i++) {
//            for (DeviceEnum de:deviceEnumList) {
//
//            }
            saveConfig(deviceEnumList);
        } else {
            //显示配置得项目
            for (int i = 0; i <deviceEnumList.size(); i++) {
                for (int j = 0; j < enumList.size(); j++) {
                    if (enumList.contains(deviceEnumList.get(i).getDeviceType())) {
                        deviceEnumList.get(i).setShow(true);
                    } else {
                        deviceEnumList.get(i).setShow(false);
                    }
                }
            }
        }
        return deviceEnumList;
    }

    public static void saveConfig(List<DeviceEnum> deviceEnumList) {
        Log.e("xiaoxin", "saveConfig: ");
        List<String> enums = new ArrayList<>();
//        for (int i = 0; i < deviceEnumList.size(); i++) {
        for (DeviceEnum de:deviceEnumList) {
            if (de.isShow) {
                enums.add(de.getDeviceType());
            }
        }
        Hawk.put(BleConfigConstants.TJ_CONFIG_LIST, enums);
    }

    private boolean isShow;

    /**
     * 设备类型 bp
     */
    private String deviceType;

    //是否需要绑定
    private boolean isBind;

    /**
     * 设备名称 血压计
     */
    private String deviceName;

    /**
     * 具体型号：如 脉搏波血压计4.0 查询绑定的蓝牙mac使用
     */
    private String title;

    /**
     * 设备mac地址
     */
    private String mac;

    private String queryIndex;
    private String mTypename;

    /**
     * 设备图标
     */
    private int icon;

    /**
     * 设备背景图
     */
    private int bg_url;

    /**
     * 具体实现类
     */
    private Class cls;



    DeviceEnum(String deviceType, boolean isBind, String deviceName, String title, String mac,
               String queryIndex, String mTypename, int icon, int bg_url, Class cls,boolean isShow) {
        this.deviceType = deviceType;
        this.isBind = isBind;
        this.deviceName = deviceName;
        this.title = title;
        this.mac = mac;
        this.queryIndex = queryIndex;
        this.mTypename = mTypename;
        this.icon = icon;
        this.bg_url = bg_url;
        this.cls = cls;
        this.isShow = isShow;
    }

    public boolean isShow() {
        return isShow;
    }

    public void setShow(boolean show) {
        isShow = show;
    }

    public boolean isBind() {
        return isBind;
    }

    public void setBind(boolean bind) {
        isBind = bind;
    }

    public boolean getIsBind() {
        return isBind;
    }

    public void setIsBind(boolean isBind) {
        this.isBind = isBind;
    }

    public String getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getMac() {
        return mac;
    }

    public void setMac(String mac) {
        this.mac = mac;
    }

    public String getQueryIndex() {
        return queryIndex;
    }

    public void setQueryIndex(String queryIndex) {
        this.queryIndex = queryIndex;
    }

    public String getmTypename() {
        return mTypename;
    }

    public void setmTypename(String mTypename) {
        this.mTypename = mTypename;
    }

    public int getIcon() {
        return icon;
    }

    public void setIcon(int icon) {
        this.icon = icon;
    }

    public int getBg_url() {
        return bg_url;
    }

    public void setBg_url(int bg_url) {
        this.bg_url = bg_url;
    }

    public Class getCls() {
        return cls;
    }

    public void setCls(Class cls) {
        this.cls = cls;
    }


}
